;; data definitions for the car order ;; ORDER (define-struct order (customer car price date)) ;; An Order is a (make-order Customer Car PosInt Date) ;; INTERP: ;; customer is the customer ordering the car ;; car is the car being ordered ;; price is the price, in USD (assumed no cents :-) ;; date is the date of the order ;; Template ;; order-fn : Order -> ?? (define (order-fn o) (... (order-customer o) (order-car o) (order-price o) (order-date o))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Customer (define-struct customer (last first address) ;; A Customer is a (make-customer String String Address) ;; interp: ;; last, first are the customer's last and first names ;; address is the customer's address (which one? mailing? delivery? ;; permanent?) ;; Template ;; customer-fn : Customer -> ?? (define (customer-fn c) (... (customer-last c) (customer-first c) (customer-address c))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Car (define-struct used-car (owner)) (define-struct new-car (ndoors ncyls sunroof? int-color ext-color) ;; A Car is one of ;; -- (make-used-car Customer) ;; -- (make-new-car NDoors NCyls Boolean PaintColor PaintColor) ;; interp: ;; for a used car: ;; -- owner is the previous owner ;; for a new car: ;; -- ndoors is the number of doors ;; -- ncyls is the number of cylinders ;; -- sunroof? tells whether or not the car has a sunroof ;; -- int-color and ext-color are interior and exterior colors of the ;; car. ;; Template: ;; car-fn : Car -> ?? (define (car-fn c) (cond [(used-car? c) (... (used-car-owner c))] [(new-car? c) (... (new-car-ndoors c) (new-car-ncyls c) (new-car-sunroof? c) (new-car-int-color c) (new-car-ext-color c))])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Address and Date will be defined elsewhere (by the "large existing ;; system") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; An NDoors is one of ;; -- 2 ;; -- 4 ;; Template: ;; ndoors-fn : NDoors -> ?? (define (ndoors-fn n) (cond [(= n 2) ...] [(= n 4) ...])) ;; NCyls similar